package com.honghu.villagepost.adapter

import com.honghu.villagepost.R
import com.honghu.villagepost.entity.Select
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder

/**
 * @author: mqwang
 * @create: 3/3/21 3:50 PM
 * @Description:
 */
class RecLeftAdapter : BaseQuickAdapter<Select, BaseViewHolder>(R.layout.adapter_rec_left) {
    override fun convert(helper: BaseViewHolder?, item: Select) {

        if (item.isSelect){
            helper!!.setVisible(R.id.line, true)
            helper!!.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.colorWhite))
        }else{
            helper!!.setVisible(R.id.line, false)
            helper!!.itemView.setBackgroundColor(mContext.getResources().getColor(R.color.uncompleted_color))
        }

        helper.setText(R.id.tv_content, item.name)

    }

    fun selectItem(position: Int){
        for (element in data){
            element.isSelect = false
            for (item in element.childList!!){
                item.isSelect = false
            }
        }
        data.get(position).isSelect = true
        notifyDataSetChanged()
    }

}